<?php
/*
    Copyright (C) 2008 - 2010 Inanta Martsanto
    
    This file is part of Koma.

    Koma is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Koma is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Koma.  If not, see <http://www.gnu.org/licenses/>.
    
    Inanta Martsanto (inanta@inationsoft.com)
*/

define('UNDEFINED_GET', 0);
define('UNDEFINED_SET', 1);
define('UNDEFINED_PROPERTY', 2);
define('ALREADY_AS_WRITE_ONLY_PROPERTY', 3);
define('ALREADY_AS_READ_ONLY_PROPERTY', 4);
define('WRITE_ONLY_PROPERTY', 5);
define('READ_ONLY_PROPERTY', 6);

final class KomaPropertyException extends KomaException
{
	public function __construct($args)
	{
		switch ($args['code'])
		{
			case UNDEFINED_GET:
				$message = sprintf(T_('Property [%s] is not exist and cannot return value'), $args['property']);
				break;
			case UNDEFINED_SET:
				$message = sprintf(T_('Property [%s] not defined before and cannot be set to [%s]'), $args['property'], $args['value']);
				break;
                        case UNDEFINED_PROPERTY:
				$message = sprintf(T_('Property [%s] not defined before and cannot be set to read only or write only property'), $args['property']);
				break;
                        case ALREADY_AS_WRITE_ONLY_PROPERTY:
				$message = sprintf(T_('Property [%s] already defined as write-only property and cannot be set as read-only property'), $args['property']);
				break;
                        case ALREADY_AS_READ_ONLY_PROPERTY:
				$message = sprintf(T_('Property [%s] already defined as read-only property and cannot be set as write-only property'), $args['property']);
				break;
                        case WRITE_ONLY_PROPERTY:
				$message = sprintf(T_('Property [%s] is write-only property and cannot return value'), $args['property']);
				break;
                        case READ_ONLY_PROPERTY:
				$message = sprintf(T_('Property [%s] is read-only property and cannot be set to [%s]'), $args['property'], $args['value']);
				break;
		}
		
		parent::__construct($message);
	}
}
?>